import { request } from "@/utils/http";

// 7. 添加到购物车(对已有物品进行数量改动)
export const requestAddShopCartOrUpdateShopNum = ({ skuId, skuNum }) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};

// 请求购物车数据
export const requestShopCartList = () => {
  return request.get("/api/cart/cartList");
};

// 删除单个商品
export const requestDeleteSingleGood = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`);
};

// 修改单个商品的选中状态
export const requestUpdateSingleChecked = (skuId, isChecked) => {
  return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`);
};

// 修改多个个商品的选中状态
export const requestUpdateAllChecked = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

// 删除已选中商品
export const requestDeleteCheckedGoods = (skuIdList) => {
  return request.delete("/api/cart/batchDeleteCart", {
    data: skuIdList,
  });
};
